package com.tuyrt.hi.hiitem.hiitem

import android.view.View
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.tuyrt.hi.hiitem.R

/**
 * author: Administrator on 2021/6/1.
 * desc:
 */
class GridDataItem(data: ItemData) : HiDataItem<ItemData, GridDataItem.MyHolder>(data) {

    override fun getItemLayoutRes(): Int {
        return R.layout.layout_list_item_grid
    }

    override fun onBindData(holder: MyHolder, position: Int) {
        holder.imageView!!.setImageResource(R.drawable.item_grid)
    }

    /**
     *  bugfix: 不能使用 inner class ，否则在HiApdater#createViewHolderInternal方法中
     *  实例化 RecyclerView.ViewHolder 的子类对象时会出错
     */

    class MyHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var imageView: ImageView? = null

        init {
            imageView = itemView.findViewById<ImageView>(R.id.item_image)
        }
    }
}